<template>
  <div id="app">
    <keep-alive>
    	<router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    	<router-view v-if="!$route.meta.keepAlive"></router-view>
	<!-- 底部导航栏' -->
	<tab-bar v-if="$route.meta.showTab"></tab-bar>
  </div>
</template>
<script>
	import TabBar from '@components/tabbar.vue'
	import {getForm2} from './request/api.js'
	export default{
		components:{
			TabBar
		},
		methods:{
			questNub(){
				return new Promise((resolve,reject)=>{
					getForm2({
						'_url':'approval1',
						'_page':1,
						'_pagesize':10,
						'system_current_changer':this.$store.state.third_name
					}).then(res=>{
						resolve(res)				
					}).catch(err=>{
						reject(err)
					})
				})				 
			},
			questNub2(){
				return new Promise((resolve,reject)=>{
					getForm2({
						'_url':'apply1',
						'party':this.$store.state.third_name
					}).then(res=>{
						resolve(res)
					}).catch(err=>{
						reject(err)
					})
				})				
			}
		},		
		created() {
			const url = window.location.hash
			Promise.all([this.questNub(), this.questNub2()]).then(res=>{
				if(res[0].code === 0){
					this.$store.commit('changTotal', res[0].total)
				} 
				if(res[1].code === 0){
					this.$store.commit('changTotal2', res[1].total)
				} 
				if(url === '#/user/approval' || url === '#/applyuser/apply' || url === '#/home' || url === '#/'){
					if(res[0].total>0){
						this.$router.push('/user/approval')
					}else if(res[1].total>0){
						this.$router.push('/applyuser/apply')
					}else{
						this.$router.push('/home')
					}
				}			
			})
		}
	}
</script>
<style lang="scss">

</style>
